package cz.uvn.orthopedy.client.entity;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import cz.uvn.orthopedy.client.ApplicationController;

public class Schedule {
	private ApplicationController controller;
	
	public Schedule(ApplicationController controller) {
		this.controller = controller;
	}
	
	public Set<Hall> getHalls(int day) {
		Set<Hall> ret = new HashSet<Hall>();
		for (Hall hall : controller.getHallsCache()) {
			for (ScheduleEntry e : controller.getScheduleEntries()) {
				if (e.getDay() == day && e.getHallId().equals(hall.getId())) {
					ret.add(hall);
					break;
				}
			}
		}
		return ret;
	}
	
	public List<ScheduleEntry> getEntries(Long hallId, int day) {
		List<ScheduleEntry> ret = new ArrayList<ScheduleEntry>();
		for (int i = 0; i < controller.getScheduleEntries().length; i++) {
			ScheduleEntry entry = controller.getScheduleEntries()[i];
			if (entry.getHallId().equals(hallId) && entry.getDay() == day) {
				ret.add(entry);
			}
		}
		return ret;
	}
}
